package com.wang.lottery.domain.activity.service.stateflow;

import com.wang.lottery.common.Constants;
import com.wang.lottery.domain.activity.service.stateflow.event.*;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wjh
 * @create 2023-11-04 18:46
 * 状态流转配置
 */
@Component
public class StateConfig {

    @Resource
    private EditingState editingState;
    @Resource
    private ArraignmentState arraignmentState;
    @Resource
    private RevokeState revokeState;
    @Resource
    private PassState passState;
    @Resource
    private CloseState closeState;
    @Resource
    private DoingState doingState;
    @Resource
    private OpenState openState;
    @Resource
    private RefuseState refuseState;
    
    protected Map<Integer, AbstractState> stateHandlerMap = new ConcurrentHashMap<>();
    
    @PostConstruct
    public void init() {
        stateHandlerMap.put(Constants.ActivityState.EDIT.getCode(),editingState);
        stateHandlerMap.put(Constants.ActivityState.ARRAIGNMENT.getCode(),arraignmentState);
        stateHandlerMap.put(Constants.ActivityState.REVOKE.getCode(),revokeState);
        stateHandlerMap.put(Constants.ActivityState.PASS.getCode(),passState);
        stateHandlerMap.put(Constants.ActivityState.DOING.getCode(),doingState);
        stateHandlerMap.put(Constants.ActivityState.REFUSE.getCode(),refuseState);
        stateHandlerMap.put(Constants.ActivityState.CLOSE.getCode(),closeState);
        stateHandlerMap.put(Constants.ActivityState.OPEN.getCode(),openState);
    }
}
